package beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@Entity
@Table(name= "Sectores")
public class Sector implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7441898995374707925L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO) 
	private int nroSector;
	
	@Column (name="Nombres", nullable=false)
	private String nombre;
	
	@OneToMany (cascade=CascadeType.ALL, fetch=FetchType.EAGER)
    @JoinColumn(name="nroSector")
    private List<Mesa> mesas;
	
	@OneToMany (cascade=CascadeType.ALL)
	@JoinColumn(name="nroSector")
    private List<Mozo> mozos;
	
	@Column (name="CantMaxMesas", nullable=false)
    private int cantMaxMesas;
	
	
  	public Sector() {
  		mesas = new ArrayList<Mesa>();
  		mozos = new ArrayList<Mozo>();
  		
	}  
    
  	
  	
  	
  	
	public String getNombre() {
		return nombre;
	}
	public void setNombre(String nombre) {
		this.nombre = nombre;
	}
	public List<Mesa> getMesas() {
		return mesas;
	}
	public void setMesas(List<Mesa> mesas) {
		this.mesas = mesas;
	}
	public List<Mozo> getMozos() {
		return mozos;
	}
	public void setMozos(List<Mozo> mozos) {
		this.mozos = mozos;
	}
	public int getCantMaxMesas() {
		return cantMaxMesas;
	}
	public void setCantMaxMesas(int cantMaxMesas) {
		this.cantMaxMesas = cantMaxMesas;
	}
	public int getNroSector() {
		return nroSector;
	}
	public void setNroSector(int nroSector) {
		this.nroSector = nroSector;
	}





	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + cantMaxMesas;
		result = prime * result + ((mesas == null) ? 0 : mesas.hashCode());
		result = prime * result + ((mozos == null) ? 0 : mozos.hashCode());
		result = prime * result + ((nombre == null) ? 0 : nombre.hashCode());
		result = prime * result + nroSector;
		return result;
	}





	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Sector other = (Sector) obj;
		if (cantMaxMesas != other.cantMaxMesas)
			return false;
		if (mesas == null) {
			if (other.mesas != null)
				return false;
		} else if (!mesas.equals(other.mesas))
			return false;
		if (mozos == null) {
			if (other.mozos != null)
				return false;
		} else if (!mozos.equals(other.mozos))
			return false;
		if (nombre == null) {
			if (other.nombre != null)
				return false;
		} else if (!nombre.equals(other.nombre))
			return false;
		if (nroSector != other.nroSector)
			return false;
		return true;
	}

    
    
}
